
****************************************************************************************
****************************************************************************************
** TABLE A1
****************************************************************************************
**************************************************************************************** 
use "${path}data_table.dta", clear

global productivity "age   npubs    citations_new np_if_3y  nb_collab_same_labex  nbpub_same_labex  nb_collabpub_same_labex  npubs_outside nb_first_same_labex "

keep if year<=2010
collapse biblio age npubs np_if_3y  mean_aut    accepted_labex   criterion_grade  criterion_grade_alt nbpub_same_labex nb_collab_same_labex nb_collabpub_same_labex nb_first_same_labex npubs_outside  nb_citations_f3_aj_y criterion_note3  nb_labex_pers citations_new, by(id_2019 labexid)  

label var age "Age (\emph{Age})"
label var npubs "Number of articles (\emph{Pubs})"
label var citations_new "Number of articles weighted by citations (\emph{Cites})" /*"Adjusted number of articles weighted by cites  (\emph{Cites})"*/
label var np_if_3y "Number of articles weighted by Impact Factor  (\emph{AIF})"
label var mean_aut "Mean number of authors  (\emph{TeamSize})"
label var nbpub_same_labex "Number of collaborative articles within the cluster (\emph{CollaPubs})"
label var nb_collabpub_same_labex "Number of collaborations within the cluster (\emph{Collaborations})"
label var nb_collab_same_labex "Number of links within the cluster (\emph{Links})"
label var nb_first_same_labex    "Number of new links within the cluster (\emph{NewLinks})"
label var npubs_outside "Number of external articles  (\emph{ExternalPubs})"
bysort id_2019: gen id=_n
bysort id_2019: egen accepted_labex2=max(accepted_labex)
local tabnom  "desc_biblio"
eststo overall: quietly estpost summarize ///
    $productivity   if  id==1 
eststo domestic: quietly estpost summarize ///
    $productivity   if biblio == 1  & id==1 
eststo foreign: quietly estpost summarize ///
    $productivity if biblio == 0  & id==1   
eststo diff: quietly estpost ttest ///
   $productivity  if     id==1 , by(biblio) unequal
esttab  domestic foreign   diff  , ///
mtitles("Core" "Periphery"  "Difference t-test") ///
cells("mean(pattern(1 1 0 ) fmt(2)) sd(pattern(1 1  0 )) b(pattern(0 0 1 ) fmt(2)) p(pattern(0 0 1 ) par fmt(2))") label
set more off
esttab   domestic foreign   diff   using `tabnom'.tex, replace ///
mtitles("Core" "Periphery"  "Difference t-test") ///
cells("mean(pattern(1 1 0 ) fmt(2)) sd(pattern(1 1  0 )) b(pattern(0 0 1 ) fmt(2)) p(pattern(0 0 1 ) par fmt(2))") label
local tabnom  "desc_biblio_criterion"
eststo overall: quietly estpost summarize ///
    $productivity   if   biblio==1 
eststo domestic: quietly estpost summarize ///
    $productivity   if biblio == 1      & criterion_grade==1
eststo foreign: quietly estpost summarize ///
    $productivity if accepted_labex == 0      & criterion_grade==1
eststo diff: quietly estpost ttest ///
   $productivity   if    criterion_grade==1, by(biblio) unequal
esttab  domestic foreign   diff  , ///
mtitles("Core" "Periphery"  "Difference t-test") ///
cells("mean(pattern(1 1 0 ) fmt(2)) sd(pattern(1 1  0 )) b(pattern(0 0 1 ) fmt(2)) p(pattern(0 0 1 ) par fmt(2))") label
set more off
esttab   domestic foreign   diff   using `tabnom'.tex, replace ///
mtitles("Core" "Periphery"  "Difference t-test") ///
cells("mean(pattern(1 1 0 ) fmt(2)) sd(pattern(1 1  0 )) b(pattern(0 0 1 ) fmt(2)) p(pattern(0 0 1 ) par fmt(2))") label


